package com.pgeneral.user.management.service.impl;

import com.pgeneral.user.management.entity.SopRole;
import com.pgeneral.user.management.util.UUIDGenerator;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;

import com.pgeneral.user.management.dao.SopRoleMapper;
import com.pgeneral.user.management.service.SopRoleService;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author 龙
 * @create 2020/6/30 11:41
 */
@Service
public class SopRoleServiceImpl implements SopRoleService {

    @Resource
    private SopRoleMapper soproleMapper;


    @Override
    @Transactional(rollbackFor = Exception.class)
    public int insert(List<SopRole> sopRoles) {
        if (sopRoles != null && sopRoles.size() > 0) {
            sopRoles.stream().forEach(sopRole -> {
                sopRole.setRoleId(UUIDGenerator.getUUID());
            });
            return soproleMapper.insert(sopRoles);
        }
        return 0;
    }

    @Override
    public List<SopRole> getSopRoleTable(SopRole sopRole) {
        return soproleMapper.getSopRoleTable(sopRole);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public int updateSopRoleTable(List<SopRole> sopRoles) {
        return soproleMapper.updateSopRoleTable(sopRoles);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public int updateIsDeletefromSopRoleTable(List<String> ids) {
        return soproleMapper.updateIsDeletefromSopRoleTable(ids);
    }
}

